package org.moka.ioio.ioiopilot.output;


import org.moka.ioio.ioiopilot.IOIOThread;

import android.util.Log;
import ioio.lib.api.IOIO;
import ioio.lib.api.PwmOutput;
import ioio.lib.api.exception.ConnectionLostException;

public class ServoOutput extends AbstractOutput {

	private PwmOutput output;
	
	public ServoOutput(IOIO ioio, int outputPin) throws ConnectionLostException
	{
		super(outputPin);
		
		output = ioio.openPwmOutput(pin, 50);		
	}
	
	public void write() throws ConnectionLostException
	{
		validate();
		output.setDutyCycle(0.05f + ((float)value/1000) * 0.05f);
		//Log.v(IOIOThread.TAG, "Servo pin "+pin+" value:"+((float)value/1000) * 0.05f);
	}
}
